#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100000+5;
int t,n,m,L,mv;
double d[N],v[N],a[N],p[N];
int sum1,mxl;
bool vis[N];
vector<pair<int,int>> ra;
bool cmp(pair<int,int> a,pair<int,int> b){
    return a.second-a.first>b.second-b.first;
}
int cnt=0;
int lower(double x){
    int k=upper_bound(p+1,p+m+1,x)-p;
    if(p[k]>x||k>m) k--;
    return k;
}
int upper(double x){
    return upper_bound(p+1,p+m+1,x)-p;
}
bool inside(int l,int r,pair<int,int> x){
    return (l<=x.first&&x.first<=r)||(l<=x.second&&x.second<=r);
}
int dfs(int l,int r,int last){
    int ans=0;
    //cout<<l<<' '<<r<<endl;
    for(int i=last;i<sum1;i++){
        if(!vis[i]&&inside(l,r,ra[i])){
            vis[i]=true;
            if(ans==0)ans+=dfs(max(l,ra[i].first),min(r,ra[i].second),i+1);
            else ans+=dfs(ra[i].first,ra[i].second,i+1);
        }
    }
    if(ans==0) ans=1;
    return ans;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        ra.clear();
        cin>>n>>m>>L>>mv;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        sum1=0,mxl=0;
        for(int i=1;i<=n;i++){
            if(a[i]<0){
                if(v[i]<mv) continue;
                else{
                    double t=(mv-v[i])/a[i];
                    double to=d[i]+v[i]*t+0.5*a[i]*t*t;
                    int l=upper(d[i]),r=lower(to);
                    if(l<=r){
                        ra.push_back(make_pair(l,r));
                        sum1++;
                    }
                }
            }else if(a[i]>0){
                if(v[i]>mv){
                    int l=upper(d[i]);
                    if(l<=m){
                        ra.push_back(make_pair(l,m));
                        sum1++;
                    }
                }else{
                    double t=(v[i]-mv)/a[i];
                    double to=d[i]+v[i]*t*0.5*a[i]*t*t;
                    int l=upper(to);
                    if(l<=m){
                        ra.push_back(make_pair(l,m));
                        sum1++;
                    }
                }
            }else{
                if(v[i]>mv){
                    int l=upper(d[i]);
                    if(l<=m){
                        ra.push_back(make_pair(l,m));
                        sum1++;
                    }
                }
            }
        }
        cout<<sum1<<' ';
        unique(ra.begin(),ra.end());
        sort(ra.begin(),ra.end(),cmp);
        cout<<m-dfs(1,m,0)<<endl;
    }
    return 0;
}
